<template>
    <div class="home_featured_hotspots_box outer_shadows">
        <div class="home_featured_hotspots_header">
            <div class="home_featured_hotspots_title">
                <slot></slot>
            </div>
            <img :src="props.img" alt="">
        </div>
        <ul>
            <li class="home_featured_hotspots_content" v-for="(item,index) in featured_hotspots" :key="index"
                :style="{'--delay': index*0.1+'s'}"
                @click="toDetail(item.id)">
                <img :src="item.cover" alt="">
                <div class="home_featured_hotspots_description">{{ item.title }}</div>
            </li>
        </ul>
    </div>
</template>
<!-- 精选热点列表-->
<script setup>
import {onMounted, ref} from "vue";
import api from "@/request/index.js";

const props = defineProps({
    img:String,
})

// 精选热点列表
const featured_hotspots = ref([
    {cover: "", title: "", id: ""},
])

//预加载
onMounted(() => {
    api.getHotArticle([]).then((res) => {
        featured_hotspots.value = res.data.data;
    })
})

//打开详情页面
const toDetail = (id) => {
    window.open("#/articleDetails?id=" + id, '_blank');
    window.localStorage.setItem("Current_option","1000");
}

</script>

<style scoped>
.home_featured_hotspots_box {
    padding: 15px;
    box-shadow: 0 0 2px rgba(63, 64, 65, 0.2);
}

ul {
    list-style: none;
}

li {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    cursor: pointer;
}

li:hover {
    color: #6da6e1;
}

.home_featured_hotspots_content {
    display: flex;
    justify-content: space-between;
    animation: home_featured_hotspots_content .2s ease-in-out 0s 1 forwards;
    animation-delay: var(--delay);
    opacity: 0;
}

.home_featured_hotspots_content img {
    width: 100px;
    aspect-ratio: 16/9;
    margin-right: 5px;
}

.home_featured_hotspots_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.home_featured_hotspots_header img {
    width: 22px;
}

.home_featured_hotspots_title {
    border-left: 3px solid #6da6e1;
    padding-left: 5px;
    line-height: inherit;
}

.home_featured_hotspots_description {
    width: 100%;
    height: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    font-size: 15px;
    transition: all .2s;
}

.home_featured_hotspots_description:hover {
    cursor: pointer;
    color: #6da6e1;
}


@keyframes home_featured_hotspots_content {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}
</style>